package com.zhiche.lisa.oms.scheduled;

import com.zhiche.lisa.oms.service.IOrderService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

@Component
public class GenerateOrderScheduled {

    private static final Logger LOGGER = LoggerFactory.getLogger(GenerateOrderScheduled.class);

    @Autowired
    private IOrderService orderService;
    @Value("${erp.fetchFlag}")
    private Boolean fetchFlag;

    /**
     * 根据发运指令生成订单 定时任务
     */
//     @Scheduled(cron = "0 5/20 * * * *")
    public void getOrder() {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         if (fetchFlag) {
             LOGGER.info(simpleDateFormat.format(new Date()) + "根据发运指令生成订单 start ====================");

             orderService.getAuthedCarrierPlate();

             LOGGER.info(simpleDateFormat.format(new Date()) + "根据发运指令生成订单 end ====================");
         }
    }
}
